#  generic_daemon.rb
#
#  This file is part of myvnet.
#
#  Copyright (C) 2008  Filipe David Borba Manana,  fdmanana@gmail.com
#
#  myvnet is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  myvnet is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with myvnet.  If not, see <http://www.gnu.org/licenses/>.


require 'lib/exceptions'
require 'lib/packet/injector'


module Daemon
  
  # Generic myvnet daemon.
  # Every myvnet daemon must subclass this class.
  # Not meant to be instantiated.
  #
  class GenericDaemon
    
    # Daemon's name. Used for debugging and logging.
    #
    attr_reader :name
    
    attr_reader :addresses
    
 
    # === Synopsis
    #
    #   Daemon::GenericDaemon.new(name, packet_injector, hwaddress, addresses)
    #
    # === Args
    #
    # +name+::
    #   Name to assign to the daemon. This name is arbitrary and is specially
    #   useful for logging and debugging.
    #   
    # +hwaddress+::
    #   Hardware address of the network interface through which packets are
    #   injected.
    #   
    # +addresses+::
    #   List of the IP addresses of the hosts that myvnet is  simulating. 
    #   At least one IP address must be provided.
    #
    # === Return
    #
    # A new myvnet daemon instance.
    #
    # === Description
    #
    # Instantiates a myvnet daemon.
    #
    def initialize(name, hwaddress, addresses)
      
      @hwaddress = hwaddress
      @name = name
      @addresses = addresses            
    end
    

    # === Synopsis
    #
    #   Daemon::GenericDaemon#process(packet)
    #
    # === Args
    #
    # +packet+::
    #   A layer 2 packet (Ethernet) captured from the network.
    #
    # === Return
    #
    # A new packet as a reply to the packet received as a parameter, or nil.
    #
    # === Description
    #
    # Processes a packet captured from the network.
    #
    def process(packet)      
    end
      
  end

end
